From: Ian Campbell Date: Tue, 12 Apr 2011 12:47:16 +0000 (+0100) Subject: tools: hvmloader: Refactor MP table setup into struct bios_config X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=575f9fbdfaf960880e04034de41c04e7323585b1;p=xen.git tools: hvmloader: Refactor MP table setup into struct bios_config Signed-off-by: Ian Campbell Acked-by: Keir Fraser --- diff --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h index de03f41744..510c017075 100644 --- a/tools/firmware/hvmloader/config.h +++ b/tools/firmware/hvmloader/config.h @@ -36,6 +36,7 @@ struct bios_config { void (*e820_setup)(void); void (*acpi_build_tables)(unsigned int physical); + void (*create_mp_tables)(void); }; extern struct bios_config rombios_config; @@ -62,11 +63,6 @@ extern unsigned long pci_mem_start, pci_mem_end; #define RESERVED_MEMBASE 0xfc000000 #define RESERVED_MEMSIZE 0x01000000 -#define ROMBIOS_BEGIN 0x000F0000 -#define ROMBIOS_SIZE 0x00010000 -#define ROMBIOS_MAXOFFSET 0x0000FFFF -#define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE) - #define SCRATCH_PHYSICAL_ADDRESS 0x00010000 #define HYPERCALL_PHYSICAL_ADDRESS 0x00080000 diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index b04a1f817a..4fcbd9c499 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -385,8 +385,9 @@ int main(void) if (bios->bios_high_setup) highbios = bios->bios_high_setup(); - if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) - create_mp_tables(); + if ( bios->create_mp_tables && + ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) ) + bios->create_mp_tables(); switch ( virtual_vga ) { diff --git a/tools/firmware/hvmloader/mp_tables.c b/tools/firmware/hvmloader/mp_tables.c index 7a79c5a1b0..668e8dd95e 100644 --- a/tools/firmware/hvmloader/mp_tables.c +++ b/tools/firmware/hvmloader/mp_tables.c @@ -259,46 +259,9 @@ static void fill_mpfps(struct mp_floating_pointer_struct *mpfps, uint32_t mpct) mpfps->checksum = -checksum; } - -/* - * find_mp_table_start - searchs through BIOS memory for '___HVMMP' signature - * - * The '___HVMMP' signature is created by the ROMBIOS and designates a chunk - * of space inside the ROMBIOS that is safe for us to write our MP table info - */ -static void *get_mp_table_start(void) -{ - char *bios_mem; - - for ( bios_mem = (char *)ROMBIOS_BEGIN; - bios_mem != (char *)ROMBIOS_END; - bios_mem++ ) - { - if ( strncmp(bios_mem, "___HVMMP", 8) == 0) - return bios_mem; - } - - return NULL; -} - - -/* recalculate the new ROMBIOS checksum after adding MP tables */ -static void reset_bios_checksum(void) -{ - uint32_t i; - uint8_t checksum; - - checksum = 0; - for (i = 0; i < ROMBIOS_MAXOFFSET; ++i) - checksum += ((uint8_t *)(ROMBIOS_BEGIN))[i]; - - *((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum; -} - /* create_mp_tables - creates MP tables for the guest based upon config data */ -void create_mp_tables(void) +void create_mp_tables(void *mp_table_base) { - void *mp_table_base; char *p; int vcpu_nr, i, length; struct mp_io_intr_entry *mpiie; @@ -307,14 +270,6 @@ void create_mp_tables(void) printf("Creating MP tables ...\n"); - /* Find the 'safe' place in ROMBIOS for the MP tables. */ - mp_table_base = get_mp_table_start(); - if ( mp_table_base == NULL ) - { - printf("Couldn't find start point for MP tables\n"); - return; - } - p = mp_table_base + sizeof(struct mp_config_table); for ( i = 0; i < vcpu_nr; i++ ) @@ -363,5 +318,4 @@ void create_mp_tables(void) (uint32_t)mp_table_base); fill_mp_config_table((struct mp_config_table *)mp_table_base, length); - reset_bios_checksum(); } diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c index ef584d325d..629a1425d4 100644 --- a/tools/firmware/hvmloader/rombios.c +++ b/tools/firmware/hvmloader/rombios.c @@ -37,6 +37,11 @@ #define ROM_INCLUDE_ROMBIOS #include "roms.inc" +#define ROMBIOS_BEGIN 0x000F0000 +#define ROMBIOS_SIZE 0x00010000 +#define ROMBIOS_MAXOFFSET 0x0000FFFF +#define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE) + /* * Set up an empty TSS area for virtual 8086 mode to use. * The only important thing is that it musn't have any bits set @@ -303,6 +308,57 @@ static void rombios_pci_setup(void) pci_writew(devfn, PCI_COMMAND, cmd); } } + +/* + * find_mp_table_start - searchs through BIOS memory for '___HVMMP' signature + * + * The '___HVMMP' signature is created by the ROMBIOS and designates a chunk + * of space inside the ROMBIOS that is safe for us to write our MP table info + */ +static void *get_mp_table_start(void) +{ + char *bios_mem; + + for ( bios_mem = (char *)ROMBIOS_BEGIN; + bios_mem != (char *)ROMBIOS_END; + bios_mem++ ) + { + if ( strncmp(bios_mem, "___HVMMP", 8) == 0) + return bios_mem; + } + + return NULL; +} + +/* recalculate the new ROMBIOS checksum after adding MP tables */ +static void reset_bios_checksum(void) +{ + uint32_t i; + uint8_t checksum; + + checksum = 0; + for (i = 0; i < ROMBIOS_MAXOFFSET; ++i) + checksum += ((uint8_t *)(ROMBIOS_BEGIN))[i]; + + *((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum; +} + +static void rombios_create_mp_tables(void) +{ + /* Find the 'safe' place in ROMBIOS for the MP tables. */ + void *table = get_mp_table_start(); + + if ( table == NULL ) + { + printf("Couldn't find start point for MP tables\n"); + return; + } + + create_mp_tables(table); + + reset_bios_checksum(); +} + //BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS)); struct bios_config rombios_config = { @@ -332,6 +388,7 @@ struct bios_config rombios_config = { .e820_setup = rombios_setup_e820, .acpi_build_tables = acpi_build_tables, + .create_mp_tables = rombios_create_mp_tables, }; /* diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 30828bb8a0..e7758ed52b 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -185,7 +185,7 @@ uint32_t rombios_highbios_setup(void); /* Miscellaneous. */ void cacheattr_init(void); -void create_mp_tables(void); +void create_mp_tables(void *table); int hvm_write_smbios_tables(unsigned long scratch, unsigned long smbios_start, unsigned long smbios_end);